<template>
	<view>
		<u-navbar placeholder fixed autoBack title="考勤管理"></u-navbar>
		<view class="search u-border-bottom d-p-l-30 d-p-r-30 d-p-t-20 d-p-b-20 d-flex">
			<view class="input d-flex d-flex-1">
				<u-icon name="search" size="38rpx" color="#ADB4BD"></u-icon>
				<view class="d-flex-1"><u--input v-model="xmmc" border="none" style="padding: 0;height: 75rpx;" placeholder="请输入项目名称查询信息"></u--input></view>
			</view>
			<u-button text="搜索" @click="init()" type="primary" :customStyle="{ width: '136rpx', height: '75rpx', marginLeft: '20rpx' }"></u-button>
		</view>
		<u-gap height="115rpx" bgColor="#ffffff"></u-gap>

		<view class="d-p-30">
			<template v-if="list && list.length > 0">
				<view class="card d-p-30 d-m-b-30" v-for="(item, index) in list" :key="index" @click="workGroup(item)">
					<view class="d-flex">
						<view class="d-font-28 d-flex-1" style="color: #151C24;font-weight: bold;">{{ item.gcmc }}</view>
						<view class="d-font-24 d-flex" style="color: #ADB4BD;">
							<view style="position: relative;top: -2rpx;">详情</view>
							<u-icon name="arrow-right" color="#ADB4BD" size="24rpx"></u-icon>
						</view>
					</view>
					<view class="d-flex d-m-t-20 d-font-24" style="color: #5D6672;">
						<view class="d-flex-1">
							<text>属地类型</text>
							<text class="d-m-l-20" style="color: #162233;">{{ item.districtName }}</text>
						</view>
						<view style="width: 260rpx;">
							<text>今日考勤数</text>
							<text class="d-m-l-20" style="color: #162233;">{{ item.atdStaff }}</text>
						</view>
					</view>
					<view class="d-flex d-m-t-20 d-font-24" style="color: #5D6672;">
						<view class="d-flex-1">
							<text>实名总人数</text>
							<text class="d-m-l-20" style="color: #162233;">{{ item.staffs }}</text>
						</view>
						<view style="width: 260rpx;">
							<text>今日考勤率</text>
							<text class="d-m-l-20" style="color: #162233;">{{ item.atdRate }}</text>
						</view>
					</view>
					<view class="d-flex d-m-t-20 d-font-24" style="color: #5D6672;">
						<view class="d-flex-1">
							<text>进场总人数</text>
							<text class="d-m-l-20" style="color: #162233;">{{ item.staffs }}</text>
						</view>
						<view style="width: 260rpx;">
							<text>考勤来源</text>
							<text class="d-m-l-20" style="color: #162233;">{{ item.sjly }}</text>
						</view>
					</view>
				</view>
			</template>
			<template v-else>
				<view style="padding: 10vh 0;"><u-empty :text="show ? '未搜索到相关数据' : '请输入关键词进行查询'" icon="/static/image/none.png"></u-empty></view>
			</template>
		</view>
	</view>
</template>

<script>
import { regionAtd } from '../../../common/api.js';
export default {
	data() {
		return {
			pageNum: 1,
			pageSize: 20,
			pageLast: 1,
			list: [],
			show: false,
			xmmc: ''
		};
	},
	onReachBottom() {
		if (this.pageNum < this.pageLast) {
			++this.pageNum;
			this.getData().then(e => {
				this.list = this.list.concat(e.data);
			});
		}
	},
	methods: {
		init() {
			if (!this.xmmc) {
				return uni.$u.toast('请输入项目名称进行查询');
			}
			this.pageNum = 1;
			uni.showLoading({
				title: '加载中...',
				mask: true
			});
			this.getList().then(e => {
				this.list = e.data;
				this.pageLast = Math.ceil(e.total / this.pageSize);
				this.show = true;
				uni.hideLoading();
			});
		},
		getList() {
			return regionAtd({
				params: {
					deptId: this.$user.deptId,
					pageSize: this.pageSize,
					xmmc: this.xmmc,
					pageNum: this.pageNum
				}
			});
		},
		workGroup(item) {
			uni.$u.route({
				url: '/pages/index/work/workGroup',
				params: {
					gcbh: item.id
				}
			});
		}
	}
};
</script>

<style lang="scss">
.search {
	position: fixed;
	left: 0;
	right: 0;
	z-index: 999;
	background-color: #ffffff;
	.input {
		height: 75rpx;
		background: #f6f7f8;
		border-radius: 10rpx;
		padding: 0 20rpx;
	}
}
.card {
	box-shadow: 0rpx 5rpx 10rpx rgba(0, 0, 0, 0.05);
	border-radius: 10rpx;
	background-color: #ffffff;
}
page {
	background-color: #fbfcfc;
}
</style>
